﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;

public partial class SiteUserMaster : System.Web.UI.MasterPage
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if (Request.UserAgent.IndexOf("AppleWebKit") > 0)
        {
            Request.Browser.Adapters.Clear();
        }

        string _strCXLive = CE.Configuration.MyConfigurationManager.GetAppSettingValue("CXCRMIsCXLive");
        if (_strCXLive == "0")
        {
            if (Session[CE.Global.General.Guest] == null)
            {
                Response.Redirect("~/Default.aspx");
            }
            //else if (Session[CE.Global.General.Guest].ToString() == "Agent")
            //{
            //    Response.Redirect("~/SiteUserSecureLogin.aspx");
            //}
        }

        if (Session[CE.Global.General.ProviderCompanyId] != null)
        {
            /*
            if (Session[CE.Global.General.ProviderCompanyId].ToString() == CE.Configuration.MyConfigurationManager.GetAppSettingValue("LibertyProviderCompanyId"))
            {
                imgLogo.ImageUrl = "~/Provider/images/logos/Liberty_insurance.gif";
                imgLogo.ToolTip = "Liberty Insurance";
                imgLogo.AlternateText = "Liberty Insurance";
                DateTime _dtLastLoginTime = Convert.ToDateTime(Session[CE.Global.General.LastLoginTime].ToString());
                divProviderInfo.InnerHtml = "Welcome " + Session[CE.Global.General.UserName].ToString() + ", Liberty Insurance Singapore<br /><span>Last login date : " + _dtLastLoginTime.ToShortDateString() + " " + _dtLastLoginTime.ToShortTimeString() + "</span>";

                litTitlePage.Text = "Liberty Insurance";

            }
            else if (Session[CE.Global.General.ProviderCompanyId].ToString() == CE.Configuration.MyConfigurationManager.GetAppSettingValue("EtiqaProviderCompanyId"))
            {
                imgLogo.ImageUrl = "~/Provider/images/logos/Etiqa.gif";
                imgLogo.ToolTip = "Etiqa Insurance";
                imgLogo.AlternateText = "Etiqa Insurance";
                DateTime _dtLastLoginTime = Convert.ToDateTime(Session[CE.Global.General.LastLoginTime].ToString());
                divProviderInfo.InnerHtml = "Welcome " + Session[CE.Global.General.UserName].ToString() + ", Etiqa Insurance Singapore<br /><span>Last login date : " + _dtLastLoginTime.ToShortDateString() + " " + _dtLastLoginTime.ToShortTimeString() + "</span>";
                //divProviderInfo.InnerHtml = "Welcome Mr. Chua, Etiqa Insurance Singapore<br /><span>Last login date : May 15, 2010</span>";

                litTitlePage.Text = "Etiqa Insurance";
            }
            else if (Session[CE.Global.General.ProviderCompanyId].ToString() == CE.Configuration.MyConfigurationManager.GetAppSettingValue("HSBCProviderCompanyId"))
            {
                imgLogo.ImageUrl = "~/Provider/images/logos/logo-hsbc.gif";
                imgLogo.ToolTip = "HSBC Insurance";
                imgLogo.AlternateText = "HSBC Insurance";

                DateTime _dtLastLoginTime = Convert.ToDateTime(Session[CE.Global.General.LastLoginTime].ToString());
                divProviderInfo.InnerHtml = "Welcome " + Session[CE.Global.General.UserName].ToString() + ", HSBC Insurance Singapore<br /><span>Last login date : " + _dtLastLoginTime.ToShortDateString() + " " + _dtLastLoginTime.ToShortTimeString() + "</span>";

                //divProviderInfo.InnerHtml = "Welcome Mr. Tan, HSBC Insurance Singapore<br /><span>Last login date : May 24, 2010</span>";

                litTitlePage.Text = "HSBC Insurance";
            }
            else if (Session[CE.Global.General.ProviderCompanyId].ToString() == CE.Configuration.MyConfigurationManager.GetAppSettingValue("ChartisProviderCompanyId"))
            {
                imgLogo.ImageUrl = "~/Provider/images/logos/chartis.gif";
                imgLogo.ToolTip = "Chartis Insurance";
                imgLogo.AlternateText = "Chartis Insurance";

                DateTime _dtLastLoginTime = Convert.ToDateTime(Session[CE.Global.General.LastLoginTime].ToString());
                divProviderInfo.InnerHtml = "Welcome " + Session[CE.Global.General.UserName].ToString() + ", Chartis Insurance Singapore<br /><span>Last login date : " + _dtLastLoginTime.ToShortDateString() + " " + _dtLastLoginTime.ToShortTimeString() + "</span>";

                litTitlePage.Text = "Chartis Insurance";
            }
            else if (Session[CE.Global.General.ProviderCompanyId].ToString() == CE.Configuration.MyConfigurationManager.GetAppSettingValue("MayBankProviderCompanyId"))
            {
                imgLogo.ImageUrl = "~/Provider/images/logos/maybank.gif";
                imgLogo.ToolTip = "MayBank";
                imgLogo.AlternateText = "MayBank";

                DateTime _dtLastLoginTime = Convert.ToDateTime(Session[CE.Global.General.LastLoginTime].ToString());
                divProviderInfo.InnerHtml = "Welcome " + Session[CE.Global.General.UserName].ToString() + ", MayBank Singapore<br /><span>Last login date : " + _dtLastLoginTime.ToShortDateString() + " " + _dtLastLoginTime.ToShortTimeString() + "</span>";

                litTitlePage.Text = "MayBank";
            }
            else if (Session[CE.Global.General.ProviderCompanyId].ToString() == CE.Configuration.MyConfigurationManager.GetAppSettingValue("RSAProviderCompanyId"))
            {
                imgLogo.ImageUrl = "~/Provider/images/logos/rsa.gif";
                imgLogo.ToolTip = "RSA";
                imgLogo.AlternateText = "RSA";

                DateTime _dtLastLoginTime = Convert.ToDateTime(Session[CE.Global.General.LastLoginTime].ToString());
                divProviderInfo.InnerHtml = "Welcome " + Session[CE.Global.General.UserName].ToString() + ", RSA Singapore<br /><span>Last login date : " + _dtLastLoginTime.ToShortDateString() + " " + _dtLastLoginTime.ToShortTimeString() + "</span>";

                litTitlePage.Text = "RSA";
            }
            else if (Session[CE.Global.General.ProviderCompanyId].ToString() == CE.Configuration.MyConfigurationManager.GetAppSettingValue("ChinaProviderCompanyId"))
            {
                imgLogo.ImageUrl = "~/Provider/images/logos/china.gif";
                imgLogo.ToolTip = "China Taiping Insurance";
                imgLogo.AlternateText = "China Taiping Insurance";

                if (Session[CE.Global.General.LastLoginTime] != null)
                {
                    DateTime _dtLastLoginTime = Convert.ToDateTime(Session[CE.Global.General.LastLoginTime].ToString());
                    divProviderInfo.InnerHtml = "Welcome " + Session[CE.Global.General.UserName].ToString() + ", China Taiping Insurance Singapore<br /><span>Last login date : " + _dtLastLoginTime.ToShortDateString() + " " + _dtLastLoginTime.ToShortTimeString() + "</span>";
                }

                litTitlePage.Text = "China Taiping Insurance";
            }
            else if (Session[CE.Global.General.ProviderCompanyId].ToString() == CE.Configuration.MyConfigurationManager.GetAppSettingValue("EQProviderCompanyId"))
            {
                imgLogo.ImageUrl = "~/Provider/images/logos/eq.gif";
                imgLogo.ToolTip = "EQ Insurance";
                imgLogo.AlternateText = "EQ Insurance";

                if (Session[CE.Global.General.LastLoginTime] != null)
                {
                    DateTime _dtLastLoginTime = Convert.ToDateTime(Session[CE.Global.General.LastLoginTime].ToString());
                    divProviderInfo.InnerHtml = "Welcome " + Session[CE.Global.General.UserName].ToString() + ", EQ Insurance Singapore<br /><span>Last login date : " + _dtLastLoginTime.ToShortDateString() + " " + _dtLastLoginTime.ToShortTimeString() + "</span>";
                }

                litTitlePage.Text = "EQ Insurance";
            }
            else
            {
                imgLogo.Visible = false;
                divProviderInfo.InnerHtml = "No such provider company found.";
                litTitlePage.Text = "No such provider company found.";
            }
            */
        }
        else if(Session[CE.Global.General.UserId] != null)
        {
            imgLogo.Visible = false;
            DateTime _dtLastLoginTime = Convert.ToDateTime(Session[CE.Global.General.LastLoginTime].ToString());
            divProviderInfo.InnerHtml = "Welcome " + Session[CE.Global.General.UserName].ToString() + ", Teledirect Singapore<br /><span>Last login date : " + _dtLastLoginTime.ToShortDateString() + " " + _dtLastLoginTime.ToShortTimeString() + "</span>";
            litTitlePage.Text = "Agent - CompareXpress";
            hplLogInOut.Text = "Sign Out";
            hplChangePassword.Visible = false;
            hplLogInOut.NavigateUrl = "~/User/Logout.aspx";
        }
    }
}
